/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  zzz.test.component.bean.Test03
 * 
 *   Date:   2014-3-11
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2014 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package com.titan.demo.camel.sample.component.bean;

import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.bean.ProxyHelper;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.util.jndi.JndiContext;

import com.titan.demo.camel.utils.CamelUtils;


/**
 *
 *
 * @author Administrator
 *
 */
public class Test03 {

    public static void main(String[] args) {
        CamelContext context = null;
        try {
            JndiContext jndi = new JndiContext();
            jndi.bind("bye", new Bean03("Good Bye!"));
            
            context = new DefaultCamelContext(jndi);
            context.addRoutes(new RouteBuilder() {
                public void configure() {
                    from("direct:hello").to("bean:bye");
                }
            });
            context.start();
            
            Endpoint endpoint = context.getEndpoint("direct:hello");
            IBean03 proxy = ProxyHelper.createProxy(endpoint, IBean03.class);
            String rc = proxy.say();
            System.out.println(rc);
            
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            CamelUtils.close(context);
        }
    }

}

